package com.sjk.flink.schema;

import com.fasterxml.jackson.databind.JsonNode;
import networknt.schema.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;
import java.util.Set;

public class TimelinessKeyword extends AbstractKeyword {
    private  final Logger logger = LoggerFactory.getLogger(TimelinessKeyword.class);

    public TimelinessKeyword() {
        super("timeliness");
    }

    @Override
    public JsonValidator newValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) throws
            JsonSchemaException, Exception {
        System.out.println("CompareField_schemaPath:"+schemaPath+",schemaNodeValue:"+schemaNode+" parentSchemaNodeKv:"+ parentSchema+",validationContext="+validationContext);

        //String config = schemaNode.asText();
        /**
        AbstractJsonValidator abstractJsonValidator = new AbstractJsonValidator() {
            @Override
            public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
                System.out.println("CompareField.validate_config:"+config+",path:"+at+",node:"+ node);
                System.out.println("CompareField.validate_rootNode="+rootNode);
                return Collections.emptySet();
            }
        };
        return abstractJsonValidator;
         **/
        //System.out.println(">>>>>>>>>>>>>>>>>       "+config);
        //ValidatorTypeCode typeCode = ValidatorTypeCode.REQUIRED;
        // Set custom error message
        //typeCode.setCustomMessage(this.type.getCustomMessage());
        return new TimelinessValidator(schemaPath,schemaNode,parentSchema,validationContext, ValidatorTypeCode.TIMELINESS);
    }
}